package com.caikun.controller;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.caikun.entity.Userinfos;
import com.caikun.services.UserinfosService;
import com.fasterxml.jackson.databind.ObjectMapper;

/**
 * Servlet implementation class UpwordController
 */
public class UpwordController extends HttpServlet {
	private static final long serialVersionUID = 1L;
	private UserinfosService us = new UserinfosService();	
	
	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doPost(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
			String acc = request.getParameter("account");
			String pas = request.getParameter("password");
			String newpass = request.getParameter("newpassword");
			PrintWriter out = response.getWriter();
			
			int result = us.modifyPassword(Integer.parseInt(acc), pas, newpass);
			if(result > 0){
				out.write("{\"status\":\"666\"}");
			}else{
				out.write("{\"status\":\"444\"}");
			}
	}

}
